<template>
	<view style="width: 100%;">
		<u-input type="select" v-model="valueText" :placeholder="placeholder"  @click="open"></u-input>
		<u-picker mode="time" v-model="show" @confirm="selConfirm"></u-picker>
	</view>
</template>

<script>
	export default {
		props: {
			placeholder: String,
			value: [String, Number]
		},
		data() {
			return {
				show: false
			}
		},
		computed: {
			valueText: {
				get() {
					let _res = ''
					if (this.value !== '') {
						_res = this.$u.timeFormat(this.value, 'yyyy-mm-dd')
					}
					return _res
				},
				set() {}
			}
		},
		methods: {
			open() {
				this.show = true
			},
			selConfirm(date) {
				// this.value = date.year + '-' + date.month + '-' + date.day
				const _date = date.year + '-' + date.month + '-' + date.day
				
				this.$emit('input', new Date(_date).getTime())
			}
		}
	}
</script>
